

// 索引数组
var array1 = [];
var mixArray = ['tom', 'john', 20, true];

for (let index = 0; index < mixArray.length; index++) {
    console.log(mixArray[index]);  // 通过下标访问
}

var data = new Array(1,2,3,4,5);

// 数组转字符串
var dataStr = data.join('-');
console.log(dataStr);

var dataStr2 = data.join('');
console.log(dataStr2);    // 12345

// 字符串转数组
var title = "a b c d e";

var letters = title.split(' ')
console.log(letters);     //[ 'a', 'b', 'c', 'd', 'e' ]

// 关联数组
var assArray = new Array();
assArray['name'] = 'gavin';
assArray['age'] = 25;
assArray['job'] = 'teacher';

// length属性失效
for (const key in assArray) {
    if (assArray.hasOwnProperty(key)) {
        const element = assArray[key];
        console.log(element);        
    }
}